package com.example.demo.generator.scaffold.model;

import java.util.Objects;

/**
 * 单个生成文件的内容描述。
 */
public class GeneratedFile {

    private final String templateId;
    private final String relativePath;
    private final String content;

    private GeneratedFile(Builder builder) {
        this.templateId = builder.templateId;
        this.relativePath = builder.relativePath;
        this.content = builder.content;
    }

    public String getTemplateId() {
        return templateId;
    }

    public String getRelativePath() {
        return relativePath;
    }

    public String getContent() {
        return content;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private String templateId;
        private String relativePath;
        private String content;

        public Builder templateId(String templateId) {
            this.templateId = templateId;
            return this;
        }

        public Builder relativePath(String relativePath) {
            this.relativePath = relativePath;
            return this;
        }

        public Builder content(String content) {
            this.content = content;
            return this;
        }

        public GeneratedFile build() {
            Objects.requireNonNull(templateId, "templateId must not be null");
            Objects.requireNonNull(relativePath, "relativePath must not be null");
            Objects.requireNonNull(content, "content must not be null");
            return new GeneratedFile(this);
        }
    }
}
